<?php

/**
 * 公告板管理
 * @author administrator
 */
class newsModel extends CDBModelBase {

    public function getTabelName() {
        return "t_news";
    }

    public function getPKID() {
        return "news_id";
    }
    protected function getSequence()
	{
		return "NEWS_SEQUENCE";
	}
	
	protected $_dateColumns="pub_time";
	
	protected $_longColumns = "content";

    public function getMaxSort() {
        $obj = $this->db->executeScalar("select max(sort_num) from " . $this->getTabelName() . " where del_flag=0");

        if ($obj) {
            return (int) $obj + 10;
        } else {
            return 1;
        }
    }
    
    public function getTopForIndex()
    {
    	$sql = "select A.news_id,A.title,A.pub_time,ROWNUM row_id from 
    	(select news_id,title,to_char(pub_time,'yyyy/mm/dd') as pub_time from t_news where del_flag=0 order by sort_num desc) A WHERE ROWNUM<=10";
    	
    	return $this->db->executeDataSet($sql);
    }
}

?>
